<template>
  <a-card class="info" title="岗位">
    <template slot="extra">
      <template v-if="model.auditStatus==0">
        <a-button
          class="ruleButton"
          :ghost="true"
          type="primary"
          icon="edit"
          @click="handleEdit(model)"
          :disabled="isDisabledAuth('erpOrgPosition:edit')"
        />
        <a-divider type="vertical"/>
        <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(model.id)">
          <a-button type="primary" size="small" :disabled="isDisabledAuth('erpOrgPosition:submit')">提交</a-button>
        </a-popconfirm>
      </template>
      <template v-if="model.auditStatus==1">
        <a-button
          type="primary"
          size="small"
          @click="handleAudit(model.id)"
          :disabled="isDisabledAuth('erpOrgPosition:audit')">审核
        </a-button>
      </template>
      <template v-if="model.auditStatus==2">
        <a-popconfirm title="确定反审吗?" @confirm="() => handleCounterTrial(model.id)">
          <a-button type="primary" size="small" :disabled="isDisabledAuth('erpOrgPosition:counterTrial')">反审
          </a-button>
        </a-popconfirm>
      </template>
    </template>
    <a-row type="flex" justify="center">
      <a-col :span="24">
        <erp-org-position-form ref="realForm" :disabled="true" normal></erp-org-position-form>
      </a-col>
    </a-row>
    <a-row type="flex" justify="center">
      <a-col :span="24">
        <ErpEmployeePostDetailList ref="detailList" :postCode="postCode" :detail="model"></ErpEmployeePostDetailList>
      </a-col>
    </a-row>
    <erp-org-position-modal ref="modalForm" @ok="modalFormOk"></erp-org-position-modal>
    <audit-modal ref="auditModal" @ok="modalFormOk"></audit-modal>
  </a-card>
</template>

<script>

import { getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpOrgPositionForm from './modules/ErpOrgPositionForm'
import ErpOrgPositionModal from './modules/ErpOrgPositionModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'
import ErpEmployeePostDetailList from './ErpEmployeePostDetailList'

export default {
  name: 'ErpOrgPositionDetail',
  mixins: [JeecgListMixin, DisabledAuthFilterMixin],
  components: {
    ErpEmployeePostDetailList,
    ErpOrgPositionForm,
    ErpOrgPositionModal
  },
  data() {
    return {
      model: {},
      postCode: '',
      id: '',
        url: {
          queryById: '/api/erpmng/sys/position/queryById',
          delete: '/api/erpmng/sys/position/delete',
          submit: '/api/erpmng/sys/position/submit',
          revoke: '/api/erpmng/sys/position/revoke',
          counterTrial: '/api/erpmng/sys/position/counterTrial',
          audit: '/api/erpmng/sys/position/audit',
          overrule: '/api/erpmng/sys/position/overrule'
        },
        confirmLoading: false,
        iconStyle: { 'font-size': '20px' }
      }
    },
    created() {
    },
    watch: {
      $route(to, from) {
        this.loadData();
      }
    },
    mounted() {
    },
    methods: {
      loadData() {
        const id = this.$route.params.id;
        getAction(this.url.queryById, { id }).then((res) => {
          if (res.success) {
            const model = res.result
            this.$refs.realForm.edit(model);
            this.model = model;
            this.postCode = model.code;
            console.log(model.code);
            this.$refs.detailList.loadData(1);
          }
        })
      }
    }
  }
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';

.info {
  /deep/ .ant-card-head-title{
    flex: none;
    margin-right: 20px;
  }
  /deep/ .ant-card-extra{
    flex: 1;
    float: left;
  }
}
</style>
